export function organizeComments(comments) {
  let commentMap = new Map();

  // 将评论放入 Map 中，以评论 id 作为 key
  comments.forEach((comment) => {
    commentMap.set(comment.id, comment);
  });

  // 遍历评论，将有 replyId 的评论放入对应的父评论的 children 属性中
  comments.forEach((comment) => {
    comment["hover"] = false;
    comment["show"] = false;
    if (comment.replyId) {
      let parentComment = commentMap.get(comment.replyId);
      if (parentComment) {
        comment.content =
          "<span class='replyUser' style='color:aquamarine;font-weight:600;margin-right:10px'>@" +
          commentMap.get(comment.replyId).userInfo.nickname +
          "</span>" +
          comment.content;
      }
    }
  });
  return comments;
}


export  function organizeComments2(comments) {
  let commentMap = new Map();

  // 将评论放入 Map 中，以评论 id 作为 key
  comments.forEach((comment) => {
    commentMap.set(comment.id, comment);
  });

  // 遍历评论，将有 replyId 的评论放入对应的父评论的 children 属性中
  comments.forEach((comment) => {
    comment["hover"] = false;
    comment["show"] = false;
    if (comment.replyId) {
      let parentComment = commentMap.get(comment.replyId);
      if (parentComment) {
        comment.content =
          "<span class='replyUser' style='color:aquamarine;font-weight:600;margin-right:10px'>@" +
          commentMap.get(comment.replyId).authorInfo.nickname +
          "</span>" +
          comment.content;
      }
    }
  });
  return comments;
}